package game;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class Game extends JPanel {

	SprBall ball = new SprBall(this);
	SprSqu squ = new SprSqu(this);
	SprRec rec = new SprRec(this);
	//Racquet racquet = new Racquet(this);
	//Racquet1 racquet1 = new Racquet1(this);

	public Game() {
		addKeyListener(new KeyListener() {
			@Override
			public void keyTyped(KeyEvent e) {
			}

			@Override
			public void keyReleased(KeyEvent e) {
		//		racquet.keyReleased(e);
				//racquet1.keyReleased(e);
			}

			@Override
			public void keyPressed(KeyEvent e) {
			//	racquet.keyPressed(e);
				//racquet1.keyPressed(e);
			}
						
		}
		
		
				);
		setFocusable(true);
	}
	
	private void move() {
		ball.move();
		squ.move();
		rec.move();
	//	racquet.move();
	//	racquet1.move();
	}

	@Override
	public void paint(Graphics g) {
		super.paint(g);
		Graphics2D g2d = (Graphics2D) g;
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
				RenderingHints.VALUE_ANTIALIAS_ON);
		  ball.paint(g2d);
		  squ.paint(g2d);
		  rec.paint(g2d);
		  
		//racquet.paint(g2d);
		//racquet1.paint(g2d);
		
	}

	public static void main(String[] args) throws InterruptedException {
		JFrame frame = new JFrame("Mini Tennis");
		Game game = new Game();
		frame.add(game);
		frame.setSize(300, 400);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		while (true) {
			game.move();
			game.repaint();
			Thread.sleep(10);
		}
	}
}
